package com.ljw.vendingmachine.bean;

import android.os.Build;
import android.support.annotation.RequiresApi;



import java.io.Serializable;
import java.util.Objects;


public class Goods implements Cloneable{


    String gid;//商品
    String goodsName;//格子商品名称
    String goodsPrice;//商品价格
    String picUrl;//商品图片
    int stockNum;//格子剩余库存
    int x;//格子X轴坐标
    int y;//格子y轴坐标
    String gNo;//通道号
   // String gNo;//通道号
    boolean outSuccess=false;
    boolean outOver=false;

    public boolean isOutOver() {
        return outOver;
    }

    public void setOutOver(boolean outOver) {
        this.outOver = outOver;
    }

    public boolean isOutSuccess() {
        return outSuccess;
    }

    public void setOutSuccess(boolean outSuccess) {
        this.outSuccess = outSuccess;
        this.outOver=true;
    }

    public Goods(String gid, String goodsName, String goodsPrice, String picUrl,
                 int stockNum, int x, int y, String gridNo) {
        this.gid = gid;
        this.goodsName = goodsName;
        this.goodsPrice = goodsPrice;
        this.picUrl = picUrl;
        this.stockNum = stockNum;
        this.x = x;
        this.y = y;
        this.gNo = gridNo;
    }

    public Goods() {
    }

    public String getgNo() {
        return gNo;
    }

    public void setgNo(String gNo) {
        this.gNo = gNo;
    }

    public String getGid() {
        return this.gid;
    }
    public void setGid(String gid) {
        this.gid = gid;
    }
    public String getGoodsName() {
        return this.goodsName;
    }
    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }
    public String getGoodsPrice() {
        return this.goodsPrice;
    }
    public void setGoodsPrice(String goodsPrice) {
        this.goodsPrice = goodsPrice;
    }
    public String getPicUrl() {
        return this.picUrl;
    }
    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }
    public int getStockNum() {
        return this.stockNum;
    }
    public void setStockNum(int stockNum) {
        this.stockNum = stockNum;
    }
    public int getX() {
        return this.x;
    }
    public void setX(int x) {
        this.x = x;
    }
    public int getY() {
        return this.y;
    }
    public void setY(int y) {
        this.y = y;
    }

    @Override
    public Object clone() {
        Goods stu = null;
        try{
            stu = (Goods)super.clone();   //浅复制
        }catch(CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return stu;
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Goods goods = (Goods) o;
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return Objects.equals(gid, goods.gid);
        }else{
            return gid.equals(goods.gid);
        }
    }

    @Override
    public int hashCode() {

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            return Objects.hash(gid);
        }else{
            return gid.hashCode();
        }
    }
}
